<?php
	defined('_JEXEC') or die('Restricted access');
	require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
	$db = JFactory::getDBO();

	$query = 'SELECT a.article_image,cc.title AS category, a.id, a.title, a.alias, a.title_alias, a.introtext, a.fulltext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,' .
	' a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.attribs, a.hits, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,' .
	' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
	' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug,'.
	' CHAR_LENGTH( a.`fulltext` ) AS readmore, u.name AS author, u.usertype, g.name AS groups FROM #__content AS a' .
	' LEFT JOIN #__categories AS cc ON a.catid = cc.id' .
	' LEFT JOIN #__users AS u ON u.id = a.created_by' .
	' LEFT JOIN #__groups AS g ON a.access = g.id WHERE a.catid = 2 and a.state >=0 LIMIT 0,3';
	
	$db->setQuery( $query );
	$rows = $db->loadObjectList();
	$i = 1;
	foreach($rows as $item){
		$link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid));
		?>
        <div class="hp-col" id="hp-col-<?php echo $i;?>">
            <a href="<?php echo $link;?>">
            	<?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".$item->article_image."&w=280&h=130&zc=1' title='".$item->title."' alt='".$item->title ."' align='middle' />";?>
            </a>
            <h3><?php echo $item->title;?></h3>
            <?php echo implode(" ", array_slice(explode(" ", $item->introtext), 0, 18));?><a href="<?php echo $link;?>" class="read-more">...Læs mere</a>
        </div>
        <?php
		$i++;
	}
?>